drop function if exists get_users_by_id_func;

create or replace function get_users_by_id_func(user_id bigint)
    RETURNS TABLE
            (
                id            bigint,
                ws_id         bigint,
                fullname      varchar,
                email         varchar,
                password_hash varchar,
                created_at    timestamp with time zone
            )
    language plpgsql
as
$$
BEGIN
    RETURN QUERY
        SELECT u.id,
               u.ws_id,
               u.fullname,
               u.email,
               u.password_hash,
               u.created_at
        FROM users u
        WHERE u.id = user_id;
END
$$;
